package com.alks.function.controller;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.WebLogger;
import com.alks.entity.data.entity.*;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.data.request.PcSoleInStockReq;
import com.alks.function.data.request.order.PcOrderDataRsjRequest;
import com.alks.function.data.request.pack.*;
import com.alks.function.service.PcOrderHeadService;
import com.alks.function.service.pack.PackMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.util.List;

/**
 * @author:xxxxx
 * @create: 2023-08-01 14:49
 * @Description: 包材查询
 */
@ApiRestController("/pack")
@Api(tags = {"总经办工厂查询-包材查询","业务部-荣阳查询-面材材料查询","开发-完成采集模块"})
public class PcPackMaterialController {
    @Autowired
    private PcOrderHeadService pcOrderHeadService;
    @Autowired
    private PackMaterialService packMaterialService;

    @PostMapping("/listPcPackMaterialInStorage")
    @ApiOperation(value = "包材入库查询",tags = {"总经办工厂查询-包材查询"})
    @WebLogger
    public ResponseInfo listPcPackMaterialInStorage(@RequestBody PcPackMaterialRequest request){
       return packMaterialService.listPcPackMaterialInStorage(request);
    }

    //包材入库导出
    @PostMapping("/downloadPcPackIn")
    @WebLogger
    @ApiOperation(value = "包材入库导出",tags = {"总经办工厂查询-包材查询"})
    public void downloadPcPackIn(HttpServletResponse response,@RequestBody PcPackMaterialRequest request) throws UnsupportedEncodingException {
        packMaterialService.downloadPcPackIn(response,request);
    }
    @GetMapping("/getPcPackMaterialInStorageCondition")
    @ApiOperation(value = "包材入库条件返回",tags = {"总经办工厂查询-包材查询"})
    @WebLogger
    public ResponseInfo getPcPackMaterialInStorageCondition(){
        return packMaterialService.getPcPackMaterialInStorageCondition();
    }

    @GetMapping("/getPcPackMaterialOutCondition")
    @ApiOperation(value = "包材出库条件返回",tags = {"总经办工厂查询-包材查询"})
    @WebLogger
    public ResponseInfo getPcPackMaterialOutCondition(){
        return packMaterialService.getPcPackMaterialOutCondition();
    }

    @PostMapping("/getPackMaterialOut")
    @ApiOperation(value = "包材出库查询",tags = {"总经办工厂查询-包材查询"})
    @WebLogger
    public ResponseInfo getPackMaterialOut(@RequestBody PcPackMaterialOutRequest request){
        return packMaterialService.getPackMaterialOut(request);
    }

    //包材出库导出
    @PostMapping("/downloadPackOut")
    @ApiOperation(value = "包材出库导出",tags = {"总经办工厂查询-包材查询"})
    @WebLogger
    public void downloadPackOut(HttpServletResponse response,@RequestBody PcPackMaterialOutRequest request) throws UnsupportedEncodingException {
        packMaterialService.downloadPackOut(response,request);
    }

    @GetMapping("/getPcPackStockCondition")
    @ApiOperation(value = "包材库存条件查询",tags = {"总经办工厂查询-包材查询"})
    @WebLogger
    public ResponseInfo getPcPackStockCondition(){
        return packMaterialService.getPcPackStockCondition();
    }

    @PostMapping("/getPcPackStock")
    @ApiOperation(value = "包材库存",tags = {"总经办工厂查询-包材查询"})
    @WebLogger
    public ResponseInfo getPcPackStock(@RequestBody PcPackStockRequest request){
        return packMaterialService.getPcPackStock(request);
    }

    @GetMapping("/getPcPackStockInOut")
    @ApiOperation(value = "包材入库出库明细",tags = {"总经办工厂查询-包材查询"})
    @WebLogger
    public ResponseInfo getPcPackStockInOut(@RequestParam String mtlNo, @RequestParam String mtlName){
        return packMaterialService.getPcPackStockInOut(mtlNo,mtlName);
    }

    //面材材料条件查询
    @GetMapping("/mtl/getPcPackFaceCondition")
    @ApiOperation(value = "面材材料查询查询条件",tags = {"业务部-荣阳查询-面材材料查询"})
    @WebLogger
    public ResponseInfo getPcPackFaceCondition(@RequestParam(required = false) String levelCode1,@RequestParam(required = false) String levelCode2){
        return packMaterialService.getPcPackFaceCondition(levelCode1,levelCode2);
    }

    //面材材料查询分类资料
    @PostMapping("/mtl/getPcPackFaceMtl")
    @ApiOperation(value = "面材材料查询分类资料",tags = {"业务部-荣阳查询-面材材料查询"})
    @WebLogger
    public ResponseInfo getPcPackFaceMtl(@RequestBody PcPackFaceMtlRequest request){
        return packMaterialService.getPcPackFaceMtl(request);
    }

    //面材材料查询
    @PostMapping("/mtl/getPcPackFaceMtlDeTail")
    @ApiOperation(value = "面材材料查询",tags = {"业务部-荣阳查询-面材材料查询"})
    @WebLogger
    public ResponseInfo getPcPackFaceMtlDeTail(@RequestBody PcPackFaceMtlDetailRequest request){
        return packMaterialService.getPcPackFaceMtlDeTail(request);
    }

    @PostMapping("/downloadPcPackMtl")
    @ApiOperation(value = "面材材料导出",tags = {"业务部-荣阳查询-面材材料查询"})
    @WebLogger
    public void downloadPcPackMtl(HttpServletResponse response,@RequestBody PcPackFaceMtlDetailRequest request) throws IOException {
        packMaterialService.downloadPcPackMtl(response,request);
    }

    @PostMapping("/collect/collectAllList")
    @WebLogger
    @ApiOperation(value = "完成采集模块查询",tags = "开发-完成采集模块")
    public ResponseInfo collectAllList(@RequestBody PcOrderDataRsjRequest request,@RequestParam @ApiParam(value = "1：查询 2：查询所有采集信息") String flag){
        return packMaterialService.collectAllList(request,flag);
    }
    @GetMapping("/getProdUser")
    @ApiOperation(value = "采集员信息",tags = {"开发-完成采集模块"})
    @WebLogger
    public ResponseInfo getProdUser(@RequestParam Integer choose){
        return pcOrderHeadService.getProdUser(choose);
    }
    @PostMapping("/scanCollectAll")
    @WebLogger
    @ApiOperation(value = "扫描采集",tags = "开发-完成采集模块")
    //扫描入库根据扫描信息
    public ResponseInfo scanCollectAll(@RequestBody ScanCollectionAllReq req, @RequestParam @ApiParam(value = "1 -板房 、2 -备料 、3  -裁断 4-电雕  5-印刷 6-无缝 7-高频 8-配套  9-针车派工 10-针车完成  11-成型投产  12-成型完成 14-大底入库") String choose){
        return packMaterialService.scanCollectAll(req,choose);
    }

    @PostMapping("/updatePcOrderStatus")
    @WebLogger
    @ApiOperation(value = "修改生产数量",tags = "开发-完成采集模块")
    public ResponseInfo updatePcOrderStatus(@RequestBody PcDesignGetRep rep){
        return packMaterialService.updatePcOrderStatus(rep);
    }

    //大底入库查询
    @PostMapping("/getSolePurPreMtlOther")
    @WebLogger
    @ApiOperation(value = "选择指令",tags = "开发-完成采集模块")
    public ResponseInfo getSolePurPreMtlOther(@RequestBody PcSoleInStockReq req){
        return packMaterialService.getSolePurPreMtlOther(req);
    }

    //大底入库扫描
    @PostMapping("/scanSolePurPreMtlOther")
    @WebLogger
    @ApiOperation(value = "大底入库扫描",tags = "开发-完成采集模块")
    public ResponseInfo scanSolePurPreMtlOther(@RequestBody List<PcSoleInPcProdRep> list){
        return packMaterialService.scanSolePurPreMtlOther(list);
    }

    //删除扫描记录
    @PostMapping("/collect/deleteCollectAll")
    @WebLogger
    @ApiOperation(value = "删除扫描记录",tags = "开发-完成采集模块")
    public ResponseInfo deleteCollectAll(@RequestBody List<PcDesignGetRep> rep
            ,@RequestParam @ApiParam(required = true,value = "1 -板房 、2 -备料 、3  -裁断 、4  -电雕 、5 -印刷 、6 -无缝 、7 -高频 、8 -配套完成 、9 -针车派工 、10 -针车完成 、11 -成型投料 、12 -成型完成 、13 -出货完成、14 -大底完成、15 -成型入库 ") String choose){
        return packMaterialService.deleteFromProdStatus(rep,choose);
    }

    @PostMapping("/collect/downloadCollection")
    @WebLogger
    @ApiOperation(value = "配套采集、针车导出日报表",tags = "开发-完成采集模块")
    public void downloadCollection(HttpServletResponse response,@RequestBody PcOrderDataRsjRequest req) throws IOException {
        packMaterialService.downloadCollection(response,req);
    }
    @PostMapping("/collect/downloadCut")
    @WebLogger
    @ApiOperation(value = "裁断试板、大货采集导出日报表",tags = "开发-完成采集模块")
    public void downloadCut(HttpServletResponse response,@RequestBody PcOrderDataRsjRequest req) throws IOException{
        packMaterialService.downloadCut(response,req);
    }

    @PostMapping("/collect/scanInStatusOther")
    @WebLogger
    @ApiOperation(value = "裁断试板、大货采集/针车试板、大货采集",tags = "开发-完成采集模块")
    public ResponseInfo scanInStatusOther(@RequestBody TestBoardsScan req){
        return packMaterialService.scanInStatusOther(req);
    }

    @PostMapping("/collect/deleteByCutAStitch")
    @WebLogger
    @ApiOperation(value = "裁断/针车 - 试板、大货 删除扫描记录",tags = "开发-完成采集模块")
    public ResponseInfo deleteByCutAStitch(@RequestBody PcCutStitchRep rep,@RequestParam @ApiParam(required = true,value = "1:裁断 2：针车") String choose){
        return packMaterialService.deleteByCutAStitch(rep,choose);
    }
}
